/**
 * 轮播图
 * @type {[type]}
 */
const mongoose = require('mongoose')

const { Schema } = mongoose


const BannerSchema = new Schema({
                                                              
    name: { type: String},       //名称 

    pic: { type: String},       //图片
 
    belong: {type: Number, enum:[1,2,3,4] ,default: 1},   //1.首页

    open_type: {type: Number,default: 0},  //0:不设置 1:跳转链接 2:跳转小程序

    open_url: {type: String,},         //链接

    order: {type: Number},        //排序  由小到大

    create_at: { type: Date, default: Date.now, index: -1,select: true },
    update_at: { type: Date, default: Date.now ,select: true},
})


BannerSchema.pre('save', function (next) {
    let now = new Date()
    this.update_at = now
    
    next()
})




mongoose.model('banner', BannerSchema)
module.exports = BannerSchema

